package com.lmiot.xyclick.Util;

import com.xiaoyi.intentsdklibrary.Utils.MathUtils;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeUtils {
    public static String createSessionID() {
        return "localsession" + createID();
    }

    public static String createZfbPayID() {
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
        return "zfb" + format + RandomUtil.getRandomNum(1000, 9999);
    }

    public static String getCurrentTimeName() {
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
        if (format != null) {
            return format;
        }
        String timer02 = getTimer02();
        return timer02 == null ? "" : timer02;
    }

    public static String getCurrentTime() {
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis()));
        if (format != null) {
            return format;
        }
        String timer02 = getTimer02();
        return timer02 == null ? "" : timer02;
    }

    public static String createAutoID() {
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
        if (format == null) {
            String timer02 = getTimer02();
            if (timer02 == null) {
                return "";
            }
            return timer02 + RandomUtil.getRandomNum(1000, 9999);
        }
        return format + RandomUtil.getRandomNum(1000, 9999);
    }

    public static String getPayTime() {
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis()));
        if (format != null) {
            return format;
        }
        String timer02 = getTimer02();
        return timer02 == null ? "" : timer02;
    }

    public static String getAlarmTime() {
        String format = new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis()));
        if (format != null) {
            return format;
        }
        String timer02 = getTimer02();
        return timer02 == null ? "" : timer02;
    }

    public static String getAlarmTimeDay() {
        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()));
        if (format != null) {
            return format;
        }
        String timer02 = getTimer02();
        return timer02 == null ? "" : timer02;
    }

    public static String createActionID() {
        return "Action" + createID();
    }

    public static String getPayID() {
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
        if (format == null) {
            String timer02 = getTimer02();
            if (timer02 == null) {
                return "";
            }
            return timer02 + RandomUtil.getRandomNum(10000, 99999);
        }
        return format + RandomUtil.getRandomNum(10000, 99999);
    }

    public static String createID() {
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
        if (format == null) {
            String timer02 = getTimer02();
            if (timer02 == null) {
                return "";
            }
            return timer02 + RandomUtil.getRandomNum(1000, 9999);
        }
        return format + RandomUtil.getRandomNum(1000, 9999);
    }

    public static String createDay() {
        String format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").format(new Date(System.currentTimeMillis()));
        if (format != null) {
            return format;
        }
        String timer02 = getTimer02();
        return timer02 == null ? "" : timer02;
    }

    public static String getTimer02() {
        Calendar instance = Calendar.getInstance();
        int i = instance.get(1);
        int i2 = instance.get(5);
        int i3 = instance.get(11);
        int i4 = instance.get(12);
        int i5 = instance.get(13);
        return i + "年" + (instance.get(2) + 1) + "月" + i2 + "日" + i3 + ":" + i4 + ":" + i5;
    }

    public static Date stringToDate(String str) {
        try {
            return new SimpleDateFormat("yyyy-MM-ddHH:mm:ss").parse(str);
        } catch (Exception e) {
            e.printStackTrace();
            ToastUtil.err("时间转换错误，请重新添加！");
            return null;
        }
    }

    public static int getNoticID(String str) {
        try {
            return MathUtils.parseInt(str.substring(str.length() - 5, str.length()).replace(":", "").replace("0", "1"));
        } catch (Exception e) {
            e.printStackTrace();
            return MathUtils.randomNum(10000, 99999);
        }
    }

    public static String getWeekDay() {
        Date date = new Date();
        Calendar instance = Calendar.getInstance();
        instance.setTime(date);
        int i = instance.get(7);
        String str = i == 2 ? "1" : "0";
        if (i == 3) {
            str = "2";
        }
        if (i == 4) {
            str = "3";
        }
        if (i == 5) {
            str = "4";
        }
        if (i == 6) {
            str = "5";
        }
        return i == 7 ? "6" : str;
    }
}
